package com.jtcl.module.queue.kafka;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author sjt
 * @since 2021-01-21 13:18
 */
@RestController
@Slf4j
@RequestMapping("kafka")
public class KafkaConotroller {

    @Autowired
    KafkaTemplate<String,String> kafkaTemplate;


    @GetMapping("send")
    public Object send(@RequestParam String topic, @RequestParam String value) {
        ListenableFuture send = kafkaTemplate.send(topic, value);
        log.info("send result:"+send.isDone());
        return send;
    }

//    @KafkaListener(topics = "test",groupId = "test")
//    public void KafkaListener(String mess){
//        log.info(mess);
//    }
}
